<?php

// +----------------------------------------------------------------------
// | H1CMS © OpenSource CMS
// +----------------------------------------------------------------------
// | Copyright (c) 2014-2016 http://www.h1cms.com All rights reserved.
// | Copyright (c) 2014-2016 嘉兴领格信息技术有限公司，并保留所有权利。
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Allen <allen@lg4.cn>
// +----------------------------------------------------------------------


require __DIR__ . '/../autoload.php';

use h1cms\H1;
use Lg\View\View;
use Lg\Http\Input;
use Lg\Component\Paginator;

function indexAction() {
    $paginator = new Paginator(Input::get('page', 1), Input::get('limit', 20), Input::query());
    $query = db_table('roles');
    $total_rows = $query->count();
    $query->limit($paginator->getLimit(), $paginator->getOffset());
    $roles = $query->fetchAll();
    $paginator->setTotal($total_rows);
    screen()->addBreadcrumb(__('角色管理'), '', '', true);
    return View::make('roles_index', [
                'roles' => $roles,
                'total_rows' => $total_rows,
                'paginator' => $paginator
    ]);
}

function addAction() {
    H1::$app->screen->addBreadcrumb(__('添加用户'), '', '', true);
    return View::make('add', []);
}

function profileAction() {
    return View::make('profile', []);
}
